package com.example.springbootwebconfig.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author ljw
 * @description
 * @date 2021/11/12 7:47
 */
@WebFilter(urlPatterns={"/user/*"})
public class UserFilter implements Filter {

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        servletResponse.setContentType("text/html;charset=UTF-8");
        servletResponse.getWriter().print("<h1>通过 @WebFilter + @ServletComponentScan 注册 Filter, 增加信息</h1>");
        filterChain.doFilter(servletRequest, servletResponse);
    }


}
